package first.niuke.huawei.mediumDifficulty;

import java.util.Scanner;
import java.util.Stack;

/**
 * @ClassName HJ26
 * @description:
 * @author: 荣燊
 * @create: 2021-07-11 19:51
 **/
public class HJ26 {
    // 字符串排序

    // 栈保存字母，
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();

            // 用栈保存字母的先后顺序
            Stack<Character> stack = new Stack<>();
            for (int i=25; i>=0; i--) {
                for (int j=s.length()-1; j>=0; j--) {
                    if ((s.charAt(j) - 'a' == i) || (s.charAt(j) - 'A' == i)) {
                        stack.push(s.charAt(j));
                    }
                }
            }
            // 栈中已经保存各字母

            // 非英文字母位置不变
            char[] schar = s.toCharArray();
            for (int i=0; i<schar.length; i++) {
                if ((schar[i] >= 'a' && schar[i]<= 'z') || (schar[i] >= 'A' && schar[i]<= 'Z')) {
                    schar[i] = stack.pop();
                }
            }
            for (int i=0; i<schar.length; i++) {
                System.out.print(schar[i]);
            }
            System.out.println();
        }
    }

}
